package com.pctx.permissionorder.service.impl;

import com.pctx.permissionorder.dao.PermissionOrderMapper;
import com.pctx.permissionorder.pojo.PermissionOrder;
import com.pctx.permissionorder.pojo.PermissionOrderExample;
import com.pctx.permissionorder.service.PermissionOrderService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by chason on 2018/3/2.11:15
 */
@Service("permissionOrderService")
public class PermissionOrderServiceImpl implements PermissionOrderService {
    @Autowired
    private PermissionOrderMapper permissionOrderMapper;

    @Override
    public List<PermissionOrder> getByCompanyUuidOrUserUuid(String companyUuid, Byte status) throws Exception {
        PermissionOrderExample example = new PermissionOrderExample();
        PermissionOrderExample.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotEmpty(companyUuid))
            criteria.andCompanyUuidEqualTo(companyUuid);
        if (null != status)
            criteria.andStatusEqualTo(status);

        return permissionOrderMapper.selectByExample(example);
    }
}
